let app = getApp();
import {util} from '../../utils/util';

Component({
    options: {
        addGlobalClass: true
    },
    mixins: [],
    data: {
        active: 'color:#0AAAF4;border-color: #0AAAF4;border-width: 2px;',
        item: '',
        teacher_Boolean: true,
        teacher_ycl_Boolean: false,
        pendingSize: 0,  //待处理数
        processedSize: 0,//已处理数
    },
    lifetimes: {
        attached: function () {
            // 在组件实例进入页面节点树时执行
            console.log("在组件实例进入页面节点树时执行")
        },
        detached: function () {
            // 在组件实例被从页面节点树移除时执行
            console.log("在组件实例被从页面节点树移除时执行")
        },
    },

    pageLifetimes: {
        // 组件所在页面的生命周期函数
        show: function () {
            // 页面被展示
            console.log("页面被展示")
            this.refreshTopNumber()
        },
        hide: function () {
            // 页面被隐藏
            console.log("页面被隐藏")
        },
        resize: function () {
            // 页面尺寸变化
            console.log("页面尺寸变化")
        },
    },
    methods: {
        refreshTopNumber() {
            let _this = this;
            util.getSize(1).then(function (res) {
                _this.setData({
                    pendingSize: res,
                })
            })
            util.getSize(2).then(function (res) {
                _this.setData({
                    processedSize: res,
                })
            })
        },

        refreshData() {
            console.log("top11111111111111111111111111111")
            const teacher = this.selectComponent('#teacher')
            const teacher_ycl = this.selectComponent('#teacher_ycl')
            if (this.data.teacher_Boolean) {
                teacher.refreshData();
            } else {
                teacher_ycl.refreshData();
            }
        },


        myEventListener: function (e) {
            this.refreshTopNumber()
            console.log(e)
        },
        // 待处理
        active_sty() {
            this.setData({
                active: 'color:#0AAAF4;border-color: #0AAAF4;border-width: 2px;',
                item: '',
                teacher_Boolean: true,
                teacher_ycl_Boolean: false,
            })
        },

        // 已处理
        item_sty() {
            this.setData({
                active: '',
                item: 'color:#0AAAF4;border-color: #0AAAF4;border-width: 2px;',
                teacher_Boolean: false,
                teacher_ycl_Boolean: true,
            })
        },
    },
});

